package com.qijian.common.utils.sync;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class KingDeeManufactureData extends BaseKingDee {


    public List<JSONObject> itemGetData(String c) {
        String[] main_fields = new String[]{"FID", "FBillNo", "FBillType.FName"
                , "FSTOCKERID", "FSTOCKERID.FName"
                , "FDate", "FApproverId"
                , "FCancelStatus", "FDocumentStatus", "FCreatorId.FName", "FCreateDate", "FModifierId.FName", "FModifyDate"
                , "FApproverId.FName", "FApproveDate"
        };
        String[] detail_fields = new String[]{"FEntity_FEntryID", "FEntryWorkShopId", "FEntryWorkShopId.FName"
                , "FSrcBillType", "FSrcBillNo", "FEntrySrcInterId", "FEntrySrcEnteryId"
                , "FMaterialId", "FMaterialId.FName", "FMaterialId.FNumber", "FUnitID.FName", "FSecUnitId.FName"
                , "FAppQty", "FActualQty", "FSecActualQty", "F_ORA_BASE.F_ORA_TEXT"
                , "FPrice", "FAmount", "FPickerId", "FPickerId.FName", "FEntrtyMemo"

                , "FStockId", "FStockId.FName", "FStockLocId"
                , "FAUXPROPID.FF100001.fdatavalue"
                , "FAUXPROPID.FF100002.fdatavalue"
                , "FAUXPROPID.FF100003"
                , "FAUXPROPID.FF100004"
                , "FAUXPROPID.FF100005.fdatavalue"
                , "FAUXPROPID.FF100006.fdatavalue"
                , "FAUXPROPID.FF100007"
                , "FAUXPROPID.FF100008"
                , "FAUXPROPID.FF100009"
                , "FAUXPROPID.FF100011.FDATAVALUE"
                , "FAUXPROPID.FF100013"
                , "FAUXPROPID.FF100015.fdatavalue"
                , "FAUXPROPID.FF100016.fdatavalue"
                , "FAUXPROPID.FF100017.fdatavalue"
                , "FAUXPROPID.FF100018.fdatavalue"
                , "FAUXPROPID.FF100018.FNUMBer"
                , "FAUXPROPID.FF100019.fdatavalue"
                , "FAUXPROPID.FF100020.fdatavalue"
                , "FAUXPROPID.FF100021"
                , "FAUXPROPID.FF100022"
                , "FAUXPROPID.FF100023"
        };

        String where = "FStockOrgId = 100121" +
                (StringUtils.isNotBlank(c) ? AND + c : "");
        return getDataJson("PRD_PickMtrl", ArrayUtils.addAll(main_fields, detail_fields), where);
    }

    public List<JSONObject> itemReplenish(String c) {
        String[] main_fields = new String[]{"FID", "FBillNo", "FBillType.FName"
                , "FSTOCKERID", "FSTOCKERID.FName"
                , "FDate", "FApproverId"
                , "FCancelStatus", "FDocumentStatus", "FCreatorId.FName", "FCreateDate", "FModifierId.FName", "FModifyDate"
                , "FApproverId.FName", "FApproveDate"
        };
        String[] detail_fields = new String[]{"FEntity_FEntryID", "FEntryWorkShopId", "FEntryWorkShopId.FName"
                , "FSrcBizBillType", "FSrcBizBillNo", "FSrcBizInterId", "FSrcBizEntryId"
                , "FMaterialId", "FMaterialId.FName", "FMaterialId.FNumber", "FUnitID.FName", "FSecUnitId.FName"
                , "FAppQty", "FActualQty", "FSecActualQty", "F_ORA_BASE.F_ORA_TEXT"
                , "FPrice", "FAmount", "FPickerId", "FPickerId.FName", "FEntrtyDescription"

                , "FStockId", "FStockId.FName", "FStockLocId"
                , "FAUXPROPID.FF100001.fdatavalue"
                , "FAUXPROPID.FF100002.fdatavalue"
                , "FAUXPROPID.FF100003"
                , "FAUXPROPID.FF100004"
                , "FAUXPROPID.FF100005.fdatavalue"
                , "FAUXPROPID.FF100006.fdatavalue"
                , "FAUXPROPID.FF100007"
                , "FAUXPROPID.FF100008"
                , "FAUXPROPID.FF100009"
                , "FAUXPROPID.FF100011.FDATAVALUE"
                , "FAUXPROPID.FF100013"
                , "FAUXPROPID.FF100015.fdatavalue"
                , "FAUXPROPID.FF100016.fdatavalue"
                , "FAUXPROPID.FF100017.fdatavalue"
                , "FAUXPROPID.FF100018.fdatavalue"
                , "FAUXPROPID.FF100018.fnumber"
                , "FAUXPROPID.FF100019.fdatavalue"
                , "FAUXPROPID.FF100020.fdatavalue"
                , "FAUXPROPID.FF100021"
                , "FAUXPROPID.FF100022"
                , "FAUXPROPID.FF100023"
        };


        String where = "FStockOrgId = 100121" +
                (StringUtils.isNotBlank(c) ? AND + c : "");
        return getDataJson("PRD_FeedMtrl", ArrayUtils.addAll(main_fields, detail_fields), where);
    }


    public static void main(String[] args) {
//        System.out.println(new KingDeeManufactureData().itemGetData("FID = 100720"));
        System.out.println(new KingDeeManufactureData().itemGetData("FDate >= '2022-06-01' and FDate < '2022-07-01'"));
    }
}
